package com.glsc.ngateway.common.api.platform.dto.other;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Id;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @Author: libj
 * @Date: 2022/6/27
 * @Desc: 数字证书信息Dto
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({ "hibernateLazyInitializer", "handler" })
public class DigitalKeyDto {

    @ApiModelProperty(value = "数字证书ID")
    @Id
    @Column(name = "key_id", columnDefinition = "int COMMENT '数组证书Id'")
    private Integer keyId;

    @ApiModelProperty(value = "数字证书类别 字典： am_digital_key_class")
    private String keyClass;

    @ApiModelProperty(value = "发证机构 字典： am_digital_key_issue_branch")
    private String keyIssueBranch;

    @ApiModelProperty(value = "对应平台")
    private String keyPlatform;

    @ApiModelProperty(value = "证书有效期 格式：yyyy-MM-dd")
    private String keyExpireDate;

    @ApiModelProperty(value = "使用部门")
    private String useDepartment;

    @ApiModelProperty(value = "用途")
    private String useDesc;

    @ApiModelProperty(value = "证书序列号")
    private String keyNo;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "状态 是否在用 字典 yesno （N=否(默认) Y=是)")
    private String keyStatus = DictConstant.YES;

    @ApiModelProperty(value = "保管人账号列表")
    private String custodianList;

    @ApiModelProperty(value = "保管人名称列表")
    private String custodianNameList;

    @ApiModelProperty(value = "实际保管人账号列表")
    private String custodianListTrue;

    @ApiModelProperty(value = "实际保管人名称列表")
    private String custodianNameListTrue;

    @ApiModelProperty(value = "保管人部门id")
    private String custodianDeptId;

    @ApiModelProperty(value = "保管人部门名称")
    private String custodianDeptName;

    @ApiModelProperty(value = "是否可以编辑 字典 YesNo:（N=未删除(默认) Y=已删除)")
    private String canEdit= DictConstant.NO;

    @ApiModelProperty(value = "删除状态，字典 字典 yesno （N=否(默认) Y=是)")
    protected String keyDeleted = DictConstant.NO;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "创建人ID")
    private String createOperator;

    @ApiModelProperty(value = "创建人姓名")
    private String createOperatorName;

    //操作人员信息
    @ApiModelProperty(value = "操作来源")
    private String opSource;

    @ApiModelProperty(value = "操作动作(增加、修改)")
    private String opAction;

    @ApiModelProperty(value = "操作人员ID")
    private String opOperator;

    @ApiModelProperty(value = "操作人员姓名")
    private String opOperatorName;

    @ApiModelProperty(value = "操作时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime opTime;

    @ApiModelProperty(value = "是否已经提醒，字典 yesno （N=未提醒(默认) Y=已提醒)")
//    @Column(name = "has_remind", columnDefinition = "varchar(10) COMMENT '是否已经提醒，字典 yesno （N=未提醒(默认) Y=已提醒)'")
    protected String hasRemind = DictConstant.NO;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof DigitalKeyDto)) return false;
        DigitalKeyDto that = (DigitalKeyDto) o;
        return Objects.equals(keyId, that.keyId) && custodianList.equals(that.custodianList) && custodianNameList.equals(that.custodianNameList) && custodianListTrue.equals(that.custodianListTrue) && custodianNameListTrue.equals(that.custodianNameListTrue);
    }

    @Override
    public int hashCode() {
        return Objects.hash(keyId, custodianList, custodianNameList, custodianListTrue, custodianNameListTrue);
    }
}

